Skip to content

lightningd: wait for all plugins to gracefully shutdown#9000

Closed
ThomsenDrake wants to merge 1 commit into
ElementsProject:masterfrom
ThomsenDrake:fix/plugin-graceful-shutdown-7697
Closed

lightningd: wait for all plugins to gracefully shutdown#9000
ThomsenDrake wants to merge 1 commit into
ElementsProject:masterfrom
ThomsenDrake:fix/plugin-graceful-shutdown-7697

Conversation

@ThomsenDrake

@ThomsenDrake ThomsenDrake commented Mar 28, 2026

Copy link
Copy Markdown

Fixes #7697\n\nChangelog-Changed: lightningd now waits for all running plugins to gracefully shutdown before exiting.\n\nWhen multiple plugins are shutting down and one exits before others,\nio_loop() can return early (e.g. when num_fds drops to 0), causing\nremaining plugins to be killed immediately instead of being given their\nfull 30-second grace period.\n\nFix by wrapping io_loop() in a while loop that continues as long as\nplugins are still alive, only breaking when the timer expires.\n\nThe fix is minimal (7 lines changed) and follows the existing code\npattern. No new state tracking needed — the plugin list already\ncorrectly tracks which plugins are alive.

When multiple plugins are shutting down and one exits before others,
io_loop() can return early (e.g. when num_fds drops to 0), causing
remaining plugins to be killed immediately instead of being given their
full 30-second grace period.

Fix by wrapping io_loop() in a while loop that continues as long as
plugins are still alive, only breaking when the timer expires.

Fixes ElementsProject#7697

Changelog-Fixed: Plugins: now wait for all plugins to gracefully shutdown instead of killing remaining plugins when one exits first. ([ElementsProject#7697])
@madelinevibes madelinevibes added the BOUNTY! 🫰 A bounty is available for this PR label Mar 30, 2026
@rustyrussell rustyrussell self-assigned this May 6, 2026
@rustyrussell rustyrussell added this to the v26.06 milestone May 6, 2026
@rustyrussell

Copy link
Copy Markdown
Contributor

I don't think this is real? If it is, you should be able to have two plugins, one sleeps 5 seconds in shutdown, second sleeps 10 seconds in shutdown and then prints something. Then you can test: if you see the second one's print message, it wasn't killed.

@rustyrussell rustyrussell removed this from the v26.06 milestone May 9, 2026
@madelinevibes

Copy link
Copy Markdown
Collaborator

@ThomsenDrake closing based on Rusty's comment, and the feature has been added in 26.06 through #9111
Let me know if you have more information to re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BOUNTY! 🫰 A bounty is available for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Should wait for plugins to gracefully shutdown

3 participants